<template>
	<page-body>
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center flex_0_ibhf"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub fd0_0_ibhf'>
					<view class='flex flex-wrap align-center fd0_0_c0_ibhf' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">
						<text class='fu-iconfont2  fd0_0_c0_c0_ibhf'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='fd0_0_c1_c0_ibhf'>{{classhourName}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-end fd0_0_c0_ibhf'>
					</view>
				</view>
			
			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局结束-->
			<view>
				<benben-flex-tabs class-name='benbenTabsfd1_0_ibhf' v-model="tab" ref="benben_tabsfd1_0"
					select-mark="benben_tabsfd1_0" key="benben_tabsfd1_0" :open-title-type='false' :open-sticky='true'
					:top='0' :is-show-content='false' :scrollspy='false' :tabs-info.sync="tabsInfofd1_0">

					<scroll-view @scroll="tabsInfofd1_0.scrollX = $event.detail.scrollLeft" id="benben_tabsfd1_0"
						class="benben-tabs" style="width:750rpx" :scroll-x="true" :scroll-left="tabsInfofd1_0.moveX"
						scroll-with-animation="all .3s ease" :show-scrollbar='false' :enhanced="true">
						<view class="benben-tabs-content" id="benben_tabsfd1_0-content">
							<view id="benben_tabsfd1_0-title"
								class="benben-tabs-title flex flex align-center justify-around">
								<view
									:class="{ 'checkTitlefd1_0_ibhf': tab == '1', 'flex flex-wrap align-center': true }"
									@tap="getlist(1)" :id="`benben_tabsfd1_0-title-item-${'1'}`">

									<text>预习知识点</text>

								</view>
								<view
									:class="{ 'checkTitlefd1_0_ibhf': tab == '2', 'flex flex-wrap align-center': true }"
									@tap="getyxlist(2)" :id="`benben_tabsfd1_0-title-item-${'2'}`">

									<text>预习题</text>

								</view>
							</view>
							<view :style="{ left: tabsInfofd1_0.lineleft, maxWidth: tabsInfofd1_0.lineWidth ,}"
								id="benben_tabsfd1_0-line"
								class="benben-tabs-line flex benben-flex-tabs-line linefd1_0_ibhf"
								:class="{'benben-tabs-line-active':tabsInfofd1_0.isInit}"></view>
						</view>
					</scroll-view>

				</benben-flex-tabs>

			</view>
			<!---flex布局flex布局开始-->
			<view class=" prepare_flex_2" v-if="tab==1">
				<!-- <view class='flex flex-direction flex-wrap align-stretch prepafre_fd2_0' v-for="item in list"
					:key="item.aid" v-if="list.length>0 && isup">
					<view class='flex flex-wrap align-center prepare_fd2_0_c0'>
						<text class='prepare_fd2_0_c0_c1'>{{item.knowledgepoints_title}}</text>
						<image class='prepare_fd2_0_c0_c2' mode="aspectFit" :src='STATIC_URL+"1608.png"'
							@tap="aianalyse(item.aid,item.knowledgepoints_title)"></image>
					</view>
					<view class='flex flex-wrap align-center justify-between prepare_fd2_0_c1'>
						<view class='flex flex-wrap align-center'>
							<text class='prepare_fd2_0_c1_c0_c0'>{{$t('难易程度')}}</text>
							<view class='flex flex-wrap align-center'>
								<template v-for="starNum in [1,2,3,4,5]">
									<image v-if="item.ny >= starNum" :key="starNum"
										class='prepare_star1fd2_0_c1_c0_c1' mode="aspectFit"
										:src='STATIC_URL+"428.png"'></image>
									<image v-else :key="starNum" class='prepare_star1fd2_0_c1_c0_c1' mode="aspectFit"
										:src='STATIC_URL+"294.png"'></image>
								</template>
							</view>
						</view>
						<view class='flex flex-wrap align-center'>
							<text class='prepare_fd2_0_c1_c0_c0'>{{$t('掌握程度')}}</text>
							<view class='flex flex-wrap align-center'>
								<template v-for="starNum in [1,2,3,4,5]">
									<image v-if="item.mastery_level >= starNum" :key="starNum"
										class='prepare_star1fd2_0_c1_c1_c1' mode="aspectFit"
										:src='STATIC_URL+"428.png"'></image>
									<image v-else :key="starNum" class='prepare_star1fd2_0_c1_c0_c1' mode="aspectFit"
										:src='STATIC_URL+"294.png"'></image>
								</template>
							</view>
						</view>
					</view>
					<view class='flex flex-wrap align-center prepare_fd2_0_c2' v-if="item.show">
						<view class='flex flex-wrap align-center flex-sub prepare_fd2_0_c1'>
							<text class='prepare_fd2_0_c2_c0_c0'>{{$t('AI分析：')}}</text>
						</view>
						<u-loading-icon style="margin: 0 280rpx 0 0; width: 80rpx;" :show="item.show&&!analyse">
						</u-loading-icon>
						<view class='prepare_fd2_0_c2_c1' v-if="analyse" v-html="analyse"></view>
					</view>
				</view> -->
				<view class='flex flex-direction flex-wrap align-stretch fd2_0_ibhf' v-for="(item,index) in list" :key="index" v-if="list.length>0 && isup">
				    <view class='flex flex-direction align-stretch fd2_0_c0_ibhf'>
				        <view class='flex flex-wrap align-center'>
				            <text class='fd2_0_c0_c0_c0_ibhf'>{{item.knowledgepoints_title}}</text>
				        </view>
				        <view class='flex flex-wrap align-center fd2_0_c0_c1_ibhf'>
				            <view class='flex flex-wrap align-center'>
				                <text>难易程度：</text>
				            </view>
				            <view class='flex flex-wrap align-center'>
				                <view class='flex flex-wrap align-center'>
				                    <template v-for="starNum in [1,2,3,4,5]">
				                        <image v-if="item.ny >= starNum" :key="starNum" class='star1fd2_0_c0_c1_c1_c0_ibhf' mode="aspectFit" :src='STATIC_URL+"428.png"'></image>
				                        <image v-else :key="starNum" class='star1fd2_0_c0_c1_c1_c0_ibhf' mode="aspectFit" :src='STATIC_URL+"294.png"'></image>
				                    </template>
				                </view>
				            </view>
				        </view>
				        <view class='flex flex-wrap align-center fd2_0_c0_c1_ibhf'>
				            <view class='flex flex-wrap align-center'>
				                <text>掌握程度：</text>
				            </view>
				            <view class='flex flex-wrap align-center'>
				                <view class='flex flex-wrap align-center'>
				                    <template v-for="starNum in [1,2,3,4,5]">
				                        <image v-if="item.mastery_level >= starNum" :key="starNum" class='star1fd2_0_c0_c1_c1_c0_ibhf' mode="aspectFit" :src='STATIC_URL+"428.png"'></image>
				                        <image v-else :key="starNum" class='star1fd2_0_c0_c1_c1_c0_ibhf' mode="aspectFit" :src='STATIC_URL+"294.png"'></image>
				                    </template>
				                </view>
				            </view>
				        </view>
				    </view>
					<!-- @tap.stop="jump(item)" -->
				    <view class='flex flex-wrap align-center fd2_0_c1_ibhf' >
				        <text>学习资源</text>
				        <text class='fd2_0_c1_c1_ibhf'>{{item.zy_total}}</text>
				       <!-- <text class='fd2_0_c1_c2_ibhf'>{{item.zy_wc}}</text>
				        <text>/{{item.zy_total}}</text> -->
				        <text class='fu-iconfont2  fd2_0_c1_c4_ibhf'>&#xe7f2;</text>
				    </view>
				    <image class='fd2_0_c2_ibhf' mode="aspectFit" :src='STATIC_URL+"1608.png"' @tap="aianalyse(item.knowledgepoints_id,item.knowledgepoints_title,index)"></image>
				</view>
				
				<view v-if="list.length==0 && isup">
					<slot>
						<view class="public-page-empty">
							<image src='/static/global/order.png'></image>
							<view class="txt">暂无数据</view>
						</view>
					</slot>
				</view>
			</view>
			<view class="prepare_flex_2" v-if="tab==2">
				
				<!-- <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout list_flex_2_ibhf"  v-if="listyxt.length>0 && isup"> -->
					<view class='flex flex-direction flex-wrap align-stretch list_fd2_0_ibhf'  v-if="listyxt.length>0 && isup"  v-for="(items,indexs) in listyxt" :key='indexs'>
						<view class='flex flex-wrap align-center list_fd2_0_c0_ibhf'>
							<text>{{indexs + 1}}</text>
							<view class='flex flex-wrap align-center list_fd2_0_c0_c1_ibhf'>
								<text class='list_fd2_0_c0_c1_c0_ibhf'>{{items.question_type_name}}</text>
							</view>
						</view>
						<view class='flex flex-wrap align-center'>
							<text v-html="items.question_title"></text>
						</view>
					</view>
					
				<!-- </view> -->
				<view v-if="listyxt.length==0 && isup">
					<slot>
						<view class="public-page-empty">
							<image src='/static/global/order.png'></image>
							<view class="txt">暂无数据</view>
						</view>
					</slot>
				</view>
			</view>
			<!---flex布局flex布局结束-->
			<view 
				class="flex flex-direction flex-wrap align-center justify-center benben-position-layout flex list_flex_3_ibhf">
				<button class='list_fd3_0_ibhf' @tap.stop="jump">一键发布</button>

			</view>
			<view :style="{height: '88rpx'}"></view>


		</view>
	</page-body>
</template>
<script>
	import {
		mdToHtml
	} from '@/common/utils/mdParser.js'
	export default {
		components: {},


		data() {
			return {
				isup:false,
				tab: 1,
				"fd2_0_c1_c0_c1": 2,
				"fd2_0_c1_c1_c1": 2,
				"fd2_1_c1_c0_c1": 2,
				"fd2_1_c1_c1_c1": 2,
				"analyse": "",

				"classname": "",
				"classhourName": "",
				"datum": "",
				"aid": "687",
				lessonplanning_id: "210",
				list: [],
				listyxt:[],//
				"tabsInfofd1_0": {
					lineleft: '',
					lineWidth: '',
					moveX: 0,
					scrollX: 0,
					PageScrollX: 0,
					isInit: false
				},
				course:'',//课程id
				type:1,//1课前预习  2课后作业
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			let {
				id,
				aid,
				name,
				name2,
				course
			} = options
			if (id != undefined) this.lessonplanning_id = id
			if (name != undefined) this.classhourName = name
			if (name2 != undefined) this.classname = name2
			if (aid != undefined) this.aid = aid
			if (course != undefined) this.course = course
			this.type=options.type
			this.getlist(1)
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// ai分析
			aianalyse(id, name) {
				this.list.forEach(item => {
					item.show = false
					if (item.aid == id) {
						item.show = true
					}
				})
				this.get662c96aab794d(name)
				this.$forceUpdate()
			},

			async get662c96aab794d(name) {
				this.analyse = ""
				let data662c96aab794d = await this.$api.post(global.apiUrls.post68c910fcdbef9, {
					agent_id:'62',
					query: `针对一名学生，在进行课前预习时，请针对课程【${this.classname}】内【${this.classhourName}】下的【${name}】进行分析，指导学生进行预习`
				})
				if (data662c96aab794d.data.code != 1) {
					this.$message.info(data662c96aab794d.data.msg);
					return
				}
				let info662c96aab794d = data662c96aab794d.data.data
				this.analyse = mdToHtml(info662c96aab794d.choices[0].message.content)
				this.$forceUpdate()
			},
			// 获取课前预习知识点
			async getlist(key) {
				this.isup=false
				this.tab=1
				let data6690ebae3b794 = await this.$api.post(global.apiUrls.post68cbd5d51c6e7, {
					homework_id: this.lessonplanning_id
				})
				this.isup=true
				if (data6690ebae3b794.data.code != 1) {
					this.$message.info(data6690ebae3b794.data.msg);
					return
				}
				let info6690ebae3b794 = data6690ebae3b794.data.data
				console.log("data6690ebae3b794=>", info6690ebae3b794)
				this.list = info6690ebae3b794
				this.list.forEach(item => {
					item.show = false
					item.ny=item.difficulty=='beginner'?1:item.difficulty=='intermediate'?3:5
				})
			},
			// 
			async getyxlist(key){
				this.tab=2
				let data6690ebae3b794 = await this.$api.post(global.apiUrls.post68cbf5f3a126e, {
					homework_id: this.lessonplanning_id
				})
				if (data6690ebae3b794.data.code != 1) {
					this.$message.info(data6690ebae3b794.data.msg);
					return
				}
				let info6690ebae3b794 = data6690ebae3b794.data.data
				console.log("data6690ebae3b794=>", info6690ebae3b794)
				this.listyxt = info6690ebae3b794
				this.listyxt.forEach(item => {
					item.show = false
					item.ny=item.difficulty=='beginner'?1:item.difficulty=='intermediate'?3:5
				})
				console.log(this.listyxt)
			},
			// 预习测试
			async navs() {
				// 查看预习测试有没有发布
				let res = await this.$api.post(global.apiUrls.post669e09ab2af21, {
					teaching_id: this.aid,
					type: 1
				})

				if (res.data.code != 1) {
					this.$message.info(res.data.msg);
					return
				}

				uni.navigateTo({
					url: "/pages/kc/answer/answer?teaching_id=" + this.aid
				})
			},
			jump(){
				uni.redirectTo({
					url:'/pages/kc/teacherfbyx/teacherfbyx?id='+this.lessonplanning_id+'&course='+this.course+'&type='+this.type
				})
			}
		}
	};
</script>
<style lang="scss" scoped>
	.tab-outer {
		z-index: 99;
	}

	.checkTitlefd1_0_ibhf {
		font-weight: 700 !important;
		font-size: 28rpx !important;
		color: #333 !important;
		background-color: rgba(255, 255, 255, 1) !important;
	}

	.linefd1_0_ibhf {
		width: 40rpx;
		height: 8rpx;
		top: 80rpx;
		background: #145efd;
		background-size: 100% auto !important;
		border-radius: 4rpx;
	}

	.page {
		width: 100vw;
		height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
		overflow: hidden;
		position: relative;
	}


	.prepare_linefd1_0 {
		background: #145efd;
		width: 50rpx;
		height: 8rpx;
		top: 80rpx;
		background-size: 100% auto !important;
	}

	.checkTitlefd1_0 {
		font-weight: 700 !important;
		font-size: 28rpx !important;
		color: #333 !important;
	}

	::v-deep .prepare_benbenTabsfd1_0 {
		width: 750rpx;
		height: 90rpx;
		white-space: nowrap;
		text-align: center;
	}

	.prepare_flex_2 {
		padding: 15rpx 24rpx 32rpx 24rpx;
		height: calc(100vh - 380rpx);
		overflow: hidden;
		overflow-y: auto;
	}

	::v-deep .prepare_fd2_0_c2_c1 {
		width: 100%;
	}

	.prepare_fd2_0_c2_c0_c0 {
		color: rgba(20, 94, 253, 1);
		line-height: 40rpx;
		font-weight: 500;
		font-size: 28rpx;
	}

	.prepare_fd2_0_c2 {
		background: #f3f6f8;
		background-size: 100% auto;
		border-radius: 16rpx;
		padding: 24rpx;
	}

	.prepare_star1fd2_0_c1_c1_c1 {
		width: 24rpx;
		height: 24rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 5rpx 0rpx 5rpx;
	}

	.prepare_star1fd2_0_c1_c0_c1 {
		height: 24rpx;
		margin: 0rpx 5rpx 0rpx 5rpx;
		width: 24rpx;
	}

	.prepare_star1fd2_0_c1_c0_c1 {
		width: 24rpx;
		height: 24rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 5rpx 0rpx 5rpx;
	}

	.prepare_fd2_0_c1_c0_c0 {
		margin: 0rpx 16rpx 0rpx 0rpx;
		color: rgba(153, 153, 153, 1);
		font-size: 24rpx;
	}

	.prepare_fd2_0_c1 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.prepare_fd2_0_c0_c2 {
		width: 28rpx;
		height: 28rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.prepare_fd2_0_c0_c1 {
		color: #333;
		font-size: 28rpx;
		font-weight: 500;
		line-height: 48rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.prepare_fd2_0_c0_c0 {
		color: #333;
		font-size: 28rpx;
		font-weight: 500;
		line-height: 48rpx;
	}

	.prepare_fd2_0_c0 {
		margin: 0rpx 0rpx 18rpx 0rpx;
	}

	.prepare_fd2_0 {
		background: var(--benbenbgColor1);
		margin: 0rpx 0rpx 24rpx 0rpx;
		border-radius: 16rpx;
		background-size: 100% auto;
		padding: 32rpx 24rpx 32rpx 24rpx;
	}




	.prepare_flex_4 {
		width: 750rpx;
		height: 110rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		left: 0rpx;
		border-radius: 0rpx;
	}

	.prepare_fd4_0 {
		background: #4781f5;
		width: 100%;
		line-height: 110rpx;
		font-size: 32rpx;
		color: #fff;
		border-radius: 0rpx;
	}

	::v-deep .benbenTabsfd1_0_ibhf {
		width: 750rpx;
		height: 90rpx;
		white-space: nowrap;
		background: #fff;
		text-align: center;
	}

	.list_flex_2_ibhf {
		padding: 24rpx;
		padding-bottom: 0;

		
	}
	.list_fd2_0_ibhf {
		margin: 24rpx;
		padding: 24rpx;
		background-color: #ffffff;
		// border-bottom: 1px solid #eee;
		border-radius: 16rpx;
		margin-bottom: 24rpx;
	
		.list_fd2_0_c0_ibhf {
			margin: 0rpx 0rpx 12rpx 0rpx;
	
			.list_fd2_0_c0_c1_ibhf {
				background: #5695F7;
				height: 40rpx;
				border-radius: 8rpx;
				padding: 0rpx 10rpx 0rpx 10rpx;
				margin: 0rpx 0rpx 0rpx 20rpx;
	
				.list_fd2_0_c0_c1_c0_ibhf {
					color: var(--benbenFontColor3);
					font-size: 24rpx;
					line-height: 40rpx;
				}
			}
		}
	}

	.prepafre_fd2_0 {
		background-color: #fff;
		margin-bottom: 24rpx;
		border-radius: 16rpx;
		padding: 24rpx 24rpx 0;
	}

	.list_flex_3_ibhf {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(88rpx + var(--window-bottom));

		.list_fd3_0_ibhf {
			border-radius: 12rpx;
			width: 702rpx;
			line-height: 84rpx;
			font-size: 24rpx;
			background: #145EFD;
			color: #fff;
			height: 84rpx;
		}
	}
	.flex_0_ibhf {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background: #fff;
		background-size: 100% auto !important;
	
		.fd0_0_ibhf {
			padding: 0rpx 32rpx 0rpx 32rpx;
	
			.fd0_0_c1_c0_ibhf {
				font-size: 36rpx;
				font-weight: 700;
				color: #333333;
				line-height: 50rpx;
			}
		}
	}
	
	.fd0_0_c0_ibhf {
		width: 120rpx;
	
		.fd0_0_c0_c0_ibhf {
			font-size: 36rpx;
			color: #333;
		}
	}
	.public-page-empty {
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
		padding: 120upx 0 0 0;
	
		image {
			width: 300rpx;
			height: 300rpx;
		}
	
		.txt {
			font-size: 28upx;
			color: $uni-text-color;
			text-align: center;
			line-height: 100upx;
			color: var(--benben-loading-color, #999999);
		}
	
		.loadTips {
			line-height: 30upx;
		}
	
		.btn {
			width: 260upx;
			height: 78upx;
			line-height: 78upx;
			background: linear-gradient(309deg, rgba(254, 49, 0, 1) 0%, rgba(255, 90, 16, 1) 100%);
			opacity: 1;
			border-radius: 44upx;
			font-size: 28upx;
			color: #fff;
			text-align: center;
			margin-top: 100upx;
		}
	}
	.fd2_0_ibhf {
	    background: url(image-path('23.png')) no-repeat;
	    background-size: 100% auto;
	    height: 319rpx;
	    padding: 30rpx 40rpx 0rpx 40rpx;
	    position: relative;
		margin-bottom: 24rpx;
	    .fd2_0_c0_ibhf {
	        border-bottom: 1px solid #eee;
	        width: 100%;
	
	        .fd2_0_c0_c0_c0_ibhf {
	            color: #333333;
	            font-size: 32rpx;
	            font-weight: 400;
	            line-height: 48rpx;
	            text-align: left;
	            font-style: normal;
	            margin: 0rpx 0rpx 32rpx 0rpx;
	        }
			 .fd2_0_c0_c1_ibhf {
			            margin: 0rpx 0rpx 24rpx 0rpx;
			            color: rgba(102, 102, 102, 1);
			            font-size: 24rpx;
			        }
					.star1fd2_0_c0_c1_c1_c0_ibhf {
					    height: 28rpx;
					    margin: 0rpx 5rpx 0rpx 5rpx;
					    width: 28rpx;
					}
	    }
	
	    .fd2_0_c1_ibhf {
	        height: 88rpx;
	        margin: auto 0rpx 0rpx 0rpx;
	        font-size: 24rpx;
	        color: rgba(102, 102, 102, 1);
	
	        .fd2_0_c1_c1_ibhf {
	            margin: 0rpx 0rpx 0rpx auto;
	            color: rgba(19, 29, 52, 1);
	            font-weight: 400;
	        }
	
	        .fd2_0_c1_c2_ibhf {
	            color: rgba(20, 94, 253, 1);
	        }
	
	        .fd2_0_c1_c4_ibhf {
	            font-size: 24rpx;
	        }
	    }
	
	    .fd2_0_c2_ibhf {
	        width: 64rpx;
	        height: 64rpx;
	        border-radius: 0rpx;
	        position: absolute;
	        top: 84rpx;
	        right: 40rpx;
	    }
	}
</style>
